package com.chcit.share.generator.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.chcit.share.admin.core.page.MybatisPageHelper;
import com.chcit.share.admin.core.page.PageRequest;
import com.chcit.share.admin.core.page.PageResult;

import com.chcit.share.generator.model.TemplateGroupModel;
import com.chcit.share.generator.dao.TemplateGroupModelMapper;
import com.chcit.share.generator.service.TemplateGroupModelService;

/**
 * ---------------------------
 * 模板组 (TemplateGroupModelServiceImpl)         
 * ---------------------------
 * 作者：  liuyang
 * 时间：  2019-05-08 22:47:30
 * 说明：  我是由代码生成器生生成的
 * ---------------------------
 */
@Service
public class TemplateGroupModelServiceImpl implements TemplateGroupModelService {

	@Autowired
	private TemplateGroupModelMapper genTemplateGroupMapper;

	@Override
	public int save(TemplateGroupModel record) {
		if(record.getId() == null || record.getId() == 0) {
			return genTemplateGroupMapper.add(record);
		}
		return genTemplateGroupMapper.update(record);
	}

	@Override
	public int delete(TemplateGroupModel record) {
		return genTemplateGroupMapper.delete(record.getId());
	}

	@Override
	public int delete(List<TemplateGroupModel> records) {
		for(TemplateGroupModel record:records) {
			delete(record);
		}
		return 1;
	}

	@Override
	public TemplateGroupModel findById(Long id) {
		return genTemplateGroupMapper.findById(id);
	}

	@Override
	public PageResult findPage(PageRequest pageRequest) {
		return MybatisPageHelper.findPage(pageRequest, genTemplateGroupMapper);
	}
	
}
